package org.kojo.tdrm.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Order;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	private String name;
	
	@Persistent
	private String profileId;
	
	@Persistent
	private Date lastLogin;
	
	@Persistent(mappedBy="ownedUser") //owned task
	@Element(dependent="true") //delete task if user is delete
	@Order(extensions=@Extension(vendorName="datanucleus",key="list-ordering",value="dueDate asc"))
	private List<Task> taskSets;
	
	@Persistent
	private UserConf userConf;
	
	public User(){
		taskSets = new ArrayList<Task>();
	}
	public User(String name){
		this.name = name;
	}
	public User(String name,Date lastLogin){
		this.name = name;
		this.lastLogin = lastLogin;
	}
	public User(String name,String profileId,Date lastLogin){
		this.name = name;
		this.profileId = profileId;
		this.lastLogin = lastLogin;
	}
	
	public List<Task> getTaskSets() {
		return taskSets;
	}
	public void setTaskSets(List<Task> taskSets) {
		this.taskSets = taskSets;
	}
	public void addTaskSets(Task task){
		this.taskSets.add(task);
	}
	public UserConf getUserConf() {
		return userConf;
	}
	public void setUserConf(UserConf userConf) {
		this.userConf = userConf;
	}
	public Date getLastLogin() {
		return lastLogin;
	}
	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getProfileId() {
		return profileId;
	}
	public void setProfileId(String profileId) {
		this.profileId = profileId;
	}
	
	

	
	
}
